//
//  FirstViewController.m
//  HZTransitionAnimaDemo
//
//  Created by hz on 2017/3/30.
//  Copyright © 2017年 hz. All rights reserved.
//

#import "FirstViewController.h"
#import "DemoViewController.h"
#import "HZCustomTransitionAnimator.h"

@interface FirstViewController ()<UIViewControllerTransitioningDelegate>

@end

@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)jumpButtonAction:(id)sender
{
    DemoViewController *demoVC = [[DemoViewController alloc] init];
    
    // 默认为全屏跳转，跳转完成后会清除frome 界面，UIModalPresentationCustom 不会清除 frome 界面
    demoVC.modalPresentationStyle = UIModalPresentationFullScreen;
    
    //使用自定义转场动画
    demoVC.transitioningDelegate = self;
    
    //animated 必须设置为yes, 必须设置delegate
    [self presentViewController:demoVC animated:YES completion:nil];
}

#pragma mark -
#pragma mark UIViewControllerTransitioningDelegate

/*
 非交互式的动画代理只需要为present和dismiss提供animator即可，但是在交互式的动画代理中，还需要为present和dismiss提供交互式动画控制器
 */

//返回一个用于 present 的 Animator
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
    return [HZCustomTransitionAnimator new];
}

//返回一个用于 dismiss 的 Animator
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    return [HZCustomTransitionAnimator new];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
